home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / qbser225.zip / QBSERIAL.DOC < prev    next >
Text File  |  1992-07-04  |  33KB  |  729 lines

  1.  
  2.  
  3.  
  4.  
  5.                                  QBserial version 2.25
  6.  
  7.                   Serial I/O Routines for use with QuickBASIC & BC6/7
  8.  
  9.           This library will provide you with serial I/O communications
  10.           routines for use in QuickBASIC 4.x (with or without PDQ), and the
  11.           Microsoft Basic Compiler 7.x Professional Development System. No
  12.           longer are you forced to use the poor communications support
  13.           provided by QB.  This program will allow you to control 8250 and
  14.           16450 type communications ports (UARTS) at speeds of up to 115200
  15.           baud. Communication ports 1 - 4, and non-standard addresses are
  16.           supported. You will no longer have problems with the DTR signal.
  17.           DTR is left in the same state it was in when before you called this
  18.           driver, or it can be controlled by your program. The serial driver
  19.           includes XON/XOFF and CTS/RTS handshaking. Serial input is
  20.           interrupt driven, using any IRQ you specify (1 - 15), with incoming
  21.           XOFF flow control (if enabled), or RTS flow control (if enabled) to
  22.           prevent overrunning the input buffer. These are the same serial I/O
  23.           routines used in Sparkware's Qmail door, and the User Database
  24.           System Doors "Query Door" and "Upload Door".
  25.  
  26.           The driver was written with Microsoft's C, and compiled with
  27.           version 6.0a of that compiler. This driver is useable with
  28.           QuickBASIC version 4.x, and Basic Compiler 6.x & 7.x PDS. (With or
  29.           without PDQ). BC 1.x, QuickBASIC 2.x, and 3.x are not supported by
  30.           this driver. The reason is that versions of QuickBASIC prior to 4.0
  31.           do not support the extensive multi-language interface that QB4.x
  32.           has (via the DECLARE statement and Microsoft language extensions).
  33.           Throughout this manual QB will be used to refer to both QuickBASIC
  34.           and the Basic Compilers (6.x & 7.x PDS).
  35.  
  36.           Before the driver can be used, the following DECLARE statements
  37.           must be added to the beginning of your QB program:
  38.  
  39.           DECLARE SUB OpenComm CDECL ALIAS "_open_comm" (BYVAL Port%, BYVAL_
  40.                                IRQ%, BYVAL Wlen%, BYVAL Parity%, BYVAL Baud&,
  41.                                BYVAL HS%) 
  42.           DECLARE SUB CloseComm CDECL ALIAS "_close_comm" () 
  43.           DECLARE FUNCTION WriteChar% CDECL (BYVAL Ascii%) 
  44.           DECLARE FUNCTION ReadChar% CDECL () 
  45.           DECLARE SUB Transmit CDECL ALIAS "_transmit_string" (addr$) 
  46.           DECLARE FUNCTION DataWaiting% CDECL ALIAS "_data_waiting" () 
  47.           DECLARE SUB ClearInputBuffer CDECL ALIAS "_clear_input_buffer" () 
  48.           DECLARE SUB CarrierDetect CDECL ALIAS "_carrier_detect_flag"_
  49.                                     (BYVAL OnOff%) 
  50.           DECLARE FUNCTION CarrierLost% CDECL ALIAS "_carrier_state" ()
  51.           DECLARE SUB DTRcontrol CDECL ALIAS "_dtr" (BYVAL OnOff%)
  52.           DECLARE SUB RTScontrol CDECL ALIAS "_rts" (BYVAL OnOff%)
  53.           DECLARE FUNCTION DriverCopyright% CDECL ()
  54.  
  55.  
  56.  
  57.         QBSERIAL User Manual - V 2.25                              Page 1
  58.  
  59.  
  60.           These declarations specify all the entry points into the serial
  61.           driver, They are in the include file QBSERIAL.DEC. DO NOT change
  62.           them or the driver may not function.
  63.  
  64.           Refer to the included sample programs SIMPLE.BAS & PCBDOOR.BAS,
  65.           they use most of the calls described below.
  66.  
  67.  
  68.  
  69.                                   Port Initialization
  70.  
  71.           OpenComm Port%, IRQ%, Wordlen%, Parity%, Baudrate&, HS%
  72.  
  73.           Port%     This is an integer value. If the specified port is 1 to
  74.                     4, the driver opens that port. If you specify the port as
  75.                     ZERO (0) the driver enters "LOCAL" mode. This allows you
  76.                     to call the driver with data, but the driver won't send
  77.                     anything. This is useful when working with "doors". if
  78.                     you specify the port as any other value, QBserial will
  79.                     use that as the base address for the port. This allows
  80.                     you to work with non-standard I/O addresses. Note however
  81.                     that if you open a non-standard port, you must specify an
  82.                     IRQ value of 1 to 15
  83.  
  84.           IRQ%      Specifies which interrupt to use with this port. If the
  85.                     value of IRQ% is ZERO (0), then the default IRQ values
  86.                     are used (COM1 & COM3 use IRQ4, COM2 & COM4 use IRQ3).
  87.                     This is what most applications will use. Specify an IRQ
  88.                     value of 1 through 15 when you want to use an IRQ value
  89.                     other than the default. Such as when you want to use
  90.                     IRQ15 with COM3. NOTE: Be careful when choosing an IRQ
  91.                     value other than the default. Most machines use some of
  92.                     the other IRQ inputs for other machine functions such as
  93.                     the Hard drive and system clock. QBserial DOES NOT chain
  94.                     the interrupt, it takes it over entirely. If you choose
  95.                     an IRQ that is used for something already, your machine
  96.                     will most certainly operate improperly.
  97.  
  98.           Wordlen%  an integer specifying the word length of the serial data.
  99.                     It has a value of 7 or 8.
  100.  
  101.           Parity%   an integer, 0 = NONE, 1 = ODD, 2 = EVEN.
  102.  
  103.           BaudRate& is a LONG INTEGER representing the desired baud rate.
  104.                     Valid numbers are 0, 300, 1200, 2400, 4800, 9600, 19200,
  105.                     38400, 57600, and 115200. The value you send is NOT
  106.                     checked and I assume you could generate crazy baud rates
  107.                     if desired. 115200 is the absolute maximum rate that can
  108.                     be generated. If you specify a baud rate of ZERO then the
  109.                     serial port is used AS-IS. The rate, word length, &
  110.                     parity are NOT changed. This is useful for door operation
  111.  
  112.  
  113.         QBSERIAL User Manual - V 2.25                              Page 2
  114.  
  115.  
  116.                     since the port is already initialized at the proper
  117.                     settings when you get control.
  118.  
  119.           HS%       an integer specifying the type of handshake you wish to
  120.                     use between the CPU and Modem (or destination device).
  121.                     Valid numbers are: 0 = NO handshake, 1 = XON/XOFF, 2 =
  122.                     CTS/RTS, 3 = XON/XOFF and CTS/RTS.
  123.  
  124.  
  125.                                      Serial Output
  126.  
  127.           To send a string of data out the serial port, you use the
  128.           "Transmit" call as follows:
  129.  
  130.                Temp$ = "Transmit this..."
  131.                Transmit Temp$
  132.  
  133.                     or
  134.  
  135.                Transmit "Send this also...."
  136.  
  137.           If you want to transmit single characters, you can use the
  138.           "WriteChar" function. Transmit calls WriteChar to send the actual
  139.           characters to the port. If you wish to use WriteChar, it has the
  140.           following format:
  141.  
  142.                Status% = WriteChar(Char%)
  143.  
  144.           Char% is the integer value of the character you want to send, it is
  145.           not a string. Status% is an integer returned by WriteChar, it is
  146.           NON-ZERO if the character was actually sent to the port, and ZERO
  147.           if the character was not sent. WriteChar will loop indefinitely on
  148.           CTS hold, XOFF hold, or Transmit Buffer Busy. These loops will exit
  149.           if carrier is lost in FULL or PARTIAL modes and return a ZERO
  150.           status%. WriteChar gives you more low level control of the sending
  151.           of characters, but you must send each character separately and
  152.           monitor its status.
  153.  
  154.           The Transmit function monitors the status of its calls to WriteChar
  155.           and triggers QuickBASIC's User Event trap (UEVENT) if a carrier
  156.           loss occurs in FULL mode. The UEVENT trap (FULL mode) is used by